package com.news.news.web;


import com.news.news.modle.Link;
import com.news.news.modle.News;
import com.news.news.modle.NewsType;
import com.news.news.modle.System;
import com.news.news.service.IndexService;
import com.news.news.util.CommonResult;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping(path = "/index/indexCtl")
public class IndexController {
    @Resource
    IndexService indexService;

    @Resource
    RedisTemplate redisTemplate;

//新闻信息
    @RequestMapping(value = "/newsType")
    public CommonResult getNewsType() {
        List<NewsType> list = indexService.newsTypeList();
        CommonResult commonResult = new CommonResult(200, list, "成功");
        return commonResult;
    }

    //链接
    @RequestMapping(value = "/link")
    public CommonResult getLink() {
        List<Link> list = indexService.getLink();
        CommonResult commonResult = new CommonResult(200, list, "成功");
        return commonResult;
    }
    //系统信息
    @RequestMapping(value="/System")
    public CommonResult getSystem() {
        System system = indexService.getSystem();
        CommonResult commonResult = new CommonResult(200, system, "成功");
        return commonResult;
    }
    //前20条新闻
    @RequestMapping(value = "/getNews")
    public CommonResult getNews() {
        List<News> list = indexService.getNews();
        CommonResult commonResult = new CommonResult(200, list, "成功");
        return commonResult;
    }
    //查询新闻信息
    @RequestMapping(value = "/queryNews")
    public CommonResult queryNews(String name) {
        List<News> list = indexService.queryNews(name);
        CommonResult commonResult = new CommonResult(200, list, "成功");
        return commonResult;
    }
//新闻类型信息
    @RequestMapping(value = "/findNewsByid")
    public CommonResult findNewsByid(Integer id) {
        List<News> list = indexService.findNewsByid(id);
        CommonResult commonResult = new CommonResult(200, list, "成功");
        return commonResult;
    }

}
